<template>
  <div class="person">
    <h2>一辆{{ car.brand }}车，价值{{ car.price }}万</h2>
    <button @click="changeName">修改名称</button>
    <button @click="changePrice">修改价格</button>
    <hr>
    <h2>
      <li v-for="g in games" :id="g.id">{{ g.name }}</li>
    </h2>
    <button @click="changeGame">修改游戏名称</button>
  </div>
</template>

<script lang="ts" setup name="Person">
import { reactive } from 'vue'

let car = reactive({ brand: '奔驰', price: 10 })

let games = reactive([
  { id: '1', name: '英雄联盟' },
  { id: '2', name: 'QQ飞车' },
  { id: '3', name: '穿越火线' }
])

console.log(car)

function changeName() {
  car.brand = '大众'
}

function changePrice() {
  car.price += 10
}

function changeGame() {
  games[0].name = '地下城与勇士'
}

</script>

<style scoped>
.person {
  background-color: skyblue;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;
}

button {
  margin: 0 5px;
}
</style>